<template>
	<view>
		<view class="record-con" v-if="recordData.length > 0">
			<view class="record-con-item flex align-item j-between" v-for="(item,index) in recordData" :key="index">
				<view class="con-item-left">
					<view class="item-left-tit">
						{{ item.title }}
					</view>
					<view class="item-left-time">
						{{ item.createtime }}
					</view>
				</view>
				<view class="con-item-right flex align-item">
					<view class="item-right-num" v-if="type == 2">
						{{ item.vip_price }} 元
					</view>
					<view class="item-right-num" v-if="type == 1">
						+{{ item.gift_b_num }}
					</view>
					<view class="item-right-icon" v-if="type == 1">
						<image :src="imgUrl + 'static/web/icon/612c0a7e34184f8bd41931f2aa963cc.png'" mode=""></image>
					</view>
				</view>
			</view>
		</view>
		<view class="" style="margin-top: 200rpx;" v-else>
			<u-empty
			        mode="data"
			        icon="http://cdn.uviewui.com/uview/empty/data.png"
					text=" "
			>
			</u-empty>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				imgUrl: this.$http.baseUrl, // 服务器域名
				type: '', //  1 礼币记录 2会员充值记录
				recordData: [], // 存储充值记录信息
				limit: 10, // 每页的请求条件
				page: 1, // 页码
				total: 0, // 数据总数量
			}
		},
		methods: {
			// 获取充值记录信息
			getRechargeRecord(){
				var that = this
				if(that.type == 1){
					that.$http.get('api/ZhGiftOrder/index',{
						'page': that.page,
						'limit': that.limit
					}).then(res=> {
						if(res){
							that.recordData = [...that.recordData,...res.list]
							that.total = res.count
						}
					})
				}else if(that.type == 2){
					that.$http.get('api/ZhVipOrder/index',{
						'page': that.page,
						'limit': that.limit
					}).then(res=> {
						if(res){
							that.recordData = [...that.recordData,...res.list]
							that.total = res.count
						}
					})
				}
			}
		},
		onLoad(option) {
			this.type = option.type
			this.getRechargeRecord()
		},
		// 触底触发
		onReachBottom() {
			if(this.recordData.length < this.total){
				this.page++
				this.getRechargeRecord()
			}
		},
	}
</script>

<style>
page {
	background-color: #FFFFFF;
}
</style>
<style lang="scss" scoped>
.flex {
	display: flex;
}
.align-item {
	align-items: center;
}
.j-between {
	justify-content: space-between;
}
.column {
	flex-direction: column;
}
.record-con {
	padding: 0 30rpx;
}
.record-con-item {
	padding: 40rpx 0;
	border-bottom: 2rpx solid #F9F9F9;
	.con-item-left {
		.item-left-tit {
			font-size: 30rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 600;
			color: #000013;
			margin-bottom: 24rpx;
		}
		.item-left-time {
			font-size: 24rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 500;
			color: #6A6A7E;
		}
	}
	.con-item-right {
		.item-right-num {
			font-size: 36rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 600;
			color: #7F5AFF;
		}
		.item-right-icon {
			width: 40rpx;
			height: 40rpx;
			margin-left: 16rpx;
			image {
				width: 100%;
				height: 100%;
			}
		}
	}
}
</style>
